const Router = require('koa-router')
const router = new Router()
router.prefix('/api/upload')

// const { auth } = require('../middleware/auth')

router.post('/', (ctx) => {
    console.log(ctx.request.files.file)
    const file = ctx.request.files.file
    const baseName = path.basename(file.path)
    ctx.body = {
        url: `${ctx.origin}/uploads/user/avatar/${baseName}`
    }
    ctx.status = 204
}) //上传文件

module.exports = router